﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DepartMentEdit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["adminUserName"] == null)
            {
                Response.Redirect("login.aspx");
            }
            /*窗体首次载入时根据设备类别编号获取设备类别名称并加入到文本框中*/
            string dptId = Request.QueryString["departmentId"];
            this.DeviceTypeName.Text = (new Department()).GetDepartMentName(Int32.Parse(dptId));
        }

    }
    protected void Btn_Update_Click(object sender, EventArgs e)
    {
        string dptId = Request.QueryString["departmentId"];
        string dptName = this.DeviceTypeName.Text;
        Department dpt = new Department();
        if (!dpt.UpdateDepartMentName(Int32.Parse(dptId), dptName))
            Response.Write("<script>alert('" + dpt.ErrMessage + "');</script>");
        else
            Response.Write("<script>alert('修改成功!');location.href='DepartMentManage.aspx';</script>");
    }
}
